package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mappers.BlackListMapper;
import com.tanhua.dubbo.mappers.UserInfoMapper;
import com.tanhua.model.domain.BlackList;
import com.tanhua.model.domain.UserInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class BlackListApiImpl implements BlackListApi {

    @Autowired
    private BlackListMapper blackListMapper;

    @Autowired
    private UserInfoMapper userInfoMapper;
    //取消黑名单
    @Override
    public void delete(Long userId, Long deleteId) {
        //构造条件构造器
        QueryWrapper<BlackList> qw = new QueryWrapper<>();
        //配置条件
        qw.eq("user_id",userId);
        qw.eq("black_user_id",deleteId);
        //执行
        blackListMapper.delete(qw);
    }

    //分页查询黑名单列表
    @Override
    public IPage<UserInfo> findPageById(Long userId, int page, int size) {
        //构建分页参数对象
        Page<UserInfo> pages = new Page<>(page, size);
        //调用分页方法
        return userInfoMapper.findBlackList(pages,userId);
    }
}
